package com.boot.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;

import com.boot.demo.service.DemoService;

@RestController
@EnableAutoConfiguration
@ComponentScan(basePackages="com.boot.demo")
public class HelloController {
	Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private DemoService demoService;
	
	@RequestMapping("/hello")
	@ResponseBody
	public String hello() {
		return "hello springBoot,hello word";
	}

	@ResponseBody
	@GetMapping(value = "/mybatis/{str}")
	public String mybatis(@PathVariable String str) {
		String flow = demoService.queryDataStr(str);
		logger.info("xxxxxxxxxxxxxx");
		return "hello springBoot,hello mybatis  select from:"+flow;
	}

	@ResponseBody
	@GetMapping(value = "/query")
	public String query(@RequestParam(name = "q_str") String str) {
		String flow = demoService.queryDataStr(str);
		logger.info("xxxxxxxxxxxxxx");
		return "hello springBoot,hello mybatis  select from:"+flow;
	}

	@GetMapping(value = "/cache")
	public String queryCache(){
		String cacheStr =demoService.queryCache();
		return cacheStr;
	}
}
